/*
 * AsfabDeskView.java
 */
package asfabdesk.apresentacao;

import asfabdesk.dominio.Associado;
import asfabdesk.presistencia.DAO;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;

/**
 * The application's main frame.
 */
public class AsfabDeskView extends FrameView {

    public AsfabDeskView(SingleFrameApplication app) {
        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = AsfabDeskApp.getApplication().getMainFrame();
            aboutBox = new AsfabDeskAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        AsfabDeskApp.getApplication().show(aboutBox);
    }

    public void abrirIFrame(JInternalFrame janela) {
        for (JInternalFrame j : desktop.getAllFrames()) {
            if (janela.getClass() == j.getClass()) {
                j.moveToFront();
                return;
            }
        }
        desktop.add(janela);
        janela.setVisible(true);
    }

    public void acaoBuscar() {
        if (txtBusca.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "Ops, preencha corretamente o campo de busca.", "Ops", 1);
        } else {
            buscaRapida(txtBusca.getText());
        }
    }

    public void buscaRapida(String busca) {
        Associado associado = new Associado();
        if (comboBusca.getSelectedIndex() == 0) {
            associado = new DAO().localizar(Associado.class, "AssociadoPorRol", Long.parseLong(busca));
        } else if (comboBusca.getSelectedIndex() == 1) {
            associado = new DAO().localizar(Associado.class, "AssociadoPorCpf", busca);
        } else if (comboBusca.getSelectedIndex() == 2) {
            associado = new DAO().localizar(Associado.class, "AssociadoPorIdentidade", busca);
        } else if (comboBusca.getSelectedIndex() == 3) {
            associado = new DAO().localizar(Associado.class, "AssociadoPorMatricula", busca);
        }

        if (associado != null) {
            JInternalFrame iFrame = new JInternalFrame();
            try {
                iFrame = new TelaAssociadoEdt(associado);
                iFrame.setVisible(true);
                desktop.add(iFrame);
                txtBusca.setText("");
            } catch (SQLException ex) {
                Logger.getLogger(AsfabDeskView.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Ops, nenhum Associado encontrado com os dados informado.", "Ops", 1);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        pnlBarraLateral = new javax.swing.JPanel();
        pnlbuscaRol = new javax.swing.JPanel();
        btnBuscar = new javax.swing.JButton();
        txtBusca = new javax.swing.JTextField();
        comboBusca = new javax.swing.JComboBox();
        imgLogo = new javax.swing.JLabel();
        pnlMenuPrincipal = new javax.swing.JPanel();
        btnAssociados = new javax.swing.JButton();
        btnFinanceiro = new javax.swing.JButton();
        btnProcessos = new javax.swing.JButton();
        btnConvenios = new javax.swing.JButton();
        desktop = new javax.swing.JDesktopPane();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu menuArquivo = new javax.swing.JMenu();
        menuAssociados = new javax.swing.JMenuItem();
        menuFinanceiro = new javax.swing.JMenuItem();
        menuProcessos = new javax.swing.JMenuItem();
        menuConvenios = new javax.swing.JMenuItem();
        menuEmpresas = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu menuAjuda = new javax.swing.JMenu();
        javax.swing.JMenuItem itemSobre = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(asfabdesk.apresentacao.AsfabDeskApp.class).getContext().getResourceMap(AsfabDeskView.class);
        mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setPreferredSize(new java.awt.Dimension(1024, 768));

        pnlBarraLateral.setName("pnlBarraLateral"); // NOI18N
        pnlBarraLateral.setOpaque(false);
        pnlBarraLateral.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        pnlbuscaRol.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("pnlbuscaRol.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), resourceMap.getColor("pnlbuscaRol.border.titleColor"))); // NOI18N
        pnlbuscaRol.setName("pnlbuscaRol"); // NOI18N
        pnlbuscaRol.setOpaque(false);

        btnBuscar.setText(resourceMap.getString("btnBuscar.text")); // NOI18N
        btnBuscar.setActionCommand(resourceMap.getString("btnBuscar.actionCommand")); // NOI18N
        btnBuscar.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnBuscar.setName("btnBuscar"); // NOI18N
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });

        txtBusca.setFont(resourceMap.getFont("txtBusca.font")); // NOI18N
        txtBusca.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        txtBusca.setText(resourceMap.getString("txtBusca.text")); // NOI18N
        txtBusca.setName("txtBusca"); // NOI18N
        txtBusca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtBuscaActionPerformed(evt);
            }
        });

        comboBusca.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ROL", "CPF", "Identidade", "Matrícula PMAB" }));
        comboBusca.setName("comboBusca"); // NOI18N

        javax.swing.GroupLayout pnlbuscaRolLayout = new javax.swing.GroupLayout(pnlbuscaRol);
        pnlbuscaRol.setLayout(pnlbuscaRolLayout);
        pnlbuscaRolLayout.setHorizontalGroup(
            pnlbuscaRolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlbuscaRolLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlbuscaRolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnBuscar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                    .addComponent(txtBusca, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 124, Short.MAX_VALUE)
                    .addComponent(comboBusca, 0, 124, Short.MAX_VALUE))
                .addContainerGap())
        );
        pnlbuscaRolLayout.setVerticalGroup(
            pnlbuscaRolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlbuscaRolLayout.createSequentialGroup()
                .addComponent(comboBusca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtBusca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pnlBarraLateral.add(pnlbuscaRol, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 431, 160, -1));
        pnlbuscaRol.getAccessibleContext().setAccessibleName(resourceMap.getString("buscaRapida.AccessibleContext.accessibleName")); // NOI18N

        imgLogo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        imgLogo.setIcon(resourceMap.getIcon("imgLogo.icon")); // NOI18N
        imgLogo.setText(resourceMap.getString("imgLogo.text")); // NOI18N
        imgLogo.setName("imgLogo"); // NOI18N
        imgLogo.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
        pnlBarraLateral.add(imgLogo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, -1, 110));

        pnlMenuPrincipal.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("pnlMenuPrincipal.border.title"), javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), resourceMap.getColor("pnlMenuPrincipal.border.titleColor"))); // NOI18N
        pnlMenuPrincipal.setName("pnlMenuPrincipal"); // NOI18N
        pnlMenuPrincipal.setOpaque(false);

        btnAssociados.setIcon(resourceMap.getIcon("btnAssociados.icon")); // NOI18N
        btnAssociados.setText(resourceMap.getString("btnAssociados.text")); // NOI18N
        btnAssociados.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnAssociados.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        btnAssociados.setName("btnAssociados"); // NOI18N
        btnAssociados.setOpaque(false);
        btnAssociados.setPreferredSize(new java.awt.Dimension(155, 51));
        btnAssociados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAssociadosActionPerformed(evt);
            }
        });

        btnFinanceiro.setForeground(resourceMap.getColor("btnFinanceiro.foreground")); // NOI18N
        btnFinanceiro.setIcon(resourceMap.getIcon("btnFinanceiro.icon")); // NOI18N
        btnFinanceiro.setText(resourceMap.getString("btnFinanceiro.text")); // NOI18N
        btnFinanceiro.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnFinanceiro.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        btnFinanceiro.setName("btnFinanceiro"); // NOI18N
        btnFinanceiro.setOpaque(false);
        btnFinanceiro.setPreferredSize(new java.awt.Dimension(155, 51));
        btnFinanceiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFinanceiroActionPerformed(evt);
            }
        });

        btnProcessos.setForeground(resourceMap.getColor("btnProcessos.foreground")); // NOI18N
        btnProcessos.setIcon(resourceMap.getIcon("btnProcessos.icon")); // NOI18N
        btnProcessos.setText(resourceMap.getString("btnProcessos.text")); // NOI18N
        btnProcessos.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnProcessos.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        btnProcessos.setOpaque(false);

        btnConvenios.setIcon(resourceMap.getIcon("btnConvenios.icon")); // NOI18N
        btnConvenios.setText(resourceMap.getString("btnConvenios.text")); // NOI18N
        btnConvenios.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        btnConvenios.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        btnConvenios.setName("btnConvenios"); // NOI18N
        btnConvenios.setOpaque(false);
        btnConvenios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConveniosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlMenuPrincipalLayout = new javax.swing.GroupLayout(pnlMenuPrincipal);
        pnlMenuPrincipal.setLayout(pnlMenuPrincipalLayout);
        pnlMenuPrincipalLayout.setHorizontalGroup(
            pnlMenuPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlMenuPrincipalLayout.createSequentialGroup()
                .addGroup(pnlMenuPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(btnFinanceiro, javax.swing.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE)
                    .addComponent(btnAssociados, javax.swing.GroupLayout.DEFAULT_SIZE, 144, Short.MAX_VALUE)
                    .addComponent(btnProcessos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnConvenios, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(11, 11, 11))
        );
        pnlMenuPrincipalLayout.setVerticalGroup(
            pnlMenuPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlMenuPrincipalLayout.createSequentialGroup()
                .addComponent(btnAssociados, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnFinanceiro, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnProcessos, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnConvenios, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pnlBarraLateral.add(pnlMenuPrincipal, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 126, 160, -1));

        desktop.setBackground(resourceMap.getColor("desktop.background")); // NOI18N
        desktop.setName("desktop"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlBarraLateral, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(desktop, javax.swing.GroupLayout.DEFAULT_SIZE, 779, Short.MAX_VALUE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(pnlBarraLateral, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 775, Short.MAX_VALUE)
                    .addComponent(desktop, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 775, Short.MAX_VALUE))
                .addContainerGap())
        );

        menuBar.setBackground(resourceMap.getColor("menuBar.background")); // NOI18N
        menuBar.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, resourceMap.getColor("menuBar.border.matteColor"))); // NOI18N
        menuBar.setName("menuBar"); // NOI18N

        menuArquivo.setBackground(resourceMap.getColor("menuArquivo.background")); // NOI18N
        menuArquivo.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, resourceMap.getColor("menuArquivo.border.matteColor"))); // NOI18N
        menuArquivo.setText(resourceMap.getString("menuArquivo.text")); // NOI18N
        menuArquivo.setName("menuArquivo"); // NOI18N

        menuAssociados.setText(resourceMap.getString("menuAssociados.text")); // NOI18N
        menuAssociados.setName("menuAssociados"); // NOI18N
        menuAssociados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuAssociadosActionPerformed(evt);
            }
        });
        menuArquivo.add(menuAssociados);

        menuFinanceiro.setText(resourceMap.getString("menuFinanceiro.text")); // NOI18N
        menuFinanceiro.setName("menuFinanceiro"); // NOI18N
        menuArquivo.add(menuFinanceiro);

        menuProcessos.setText(resourceMap.getString("menuProcessos.text")); // NOI18N
        menuProcessos.setName("menuProcessos"); // NOI18N
        menuArquivo.add(menuProcessos);

        menuConvenios.setText(resourceMap.getString("menuConvenios.text")); // NOI18N
        menuConvenios.setName("menuConvenios"); // NOI18N
        menuConvenios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConveniosActionPerformed(evt);
            }
        });
        menuArquivo.add(menuConvenios);

        menuEmpresas.setText(resourceMap.getString("menuEmpresas.text")); // NOI18N
        menuEmpresas.setName("menuEmpresas"); // NOI18N
        menuEmpresas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuEmpresasActionPerformed(evt);
            }
        });
        menuArquivo.add(menuEmpresas);

        jSeparator1.setName("jSeparator1"); // NOI18N
        menuArquivo.add(jSeparator1);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(asfabdesk.apresentacao.AsfabDeskApp.class).getContext().getActionMap(AsfabDeskView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setBackground(resourceMap.getColor("exitMenuItem.background")); // NOI18N
        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setBorder(null);
        menuArquivo.add(exitMenuItem);

        menuBar.add(menuArquivo);

        menuAjuda.setBackground(resourceMap.getColor("menuAjuda.background")); // NOI18N
        menuAjuda.setText(resourceMap.getString("menuAjuda.text")); // NOI18N
        menuAjuda.setName("menuAjuda"); // NOI18N

        itemSobre.setAction(actionMap.get("showAboutBox")); // NOI18N
        itemSobre.setBackground(resourceMap.getColor("itemSobre.background")); // NOI18N
        itemSobre.setText(resourceMap.getString("itemSobre.text")); // NOI18N
        itemSobre.setName("itemSobre"); // NOI18N
        menuAjuda.add(itemSobre);

        menuBar.add(menuAjuda);

        jMenu1.setBackground(resourceMap.getColor("jMenu1.background")); // NOI18N
        jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
        jMenu1.setName("jMenu1"); // NOI18N
        jMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu1ActionPerformed(evt);
            }
        });

        jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
        jMenuItem1.setName("jMenuItem1"); // NOI18N
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
        jMenuItem2.setName("jMenuItem2"); // NOI18N
        jMenu1.add(jMenuItem2);

        menuBar.add(jMenu1);

        statusPanel.setBackground(resourceMap.getColor("statusPanel.background")); // NOI18N
        statusPanel.setName("statusPanel"); // NOI18N
        statusPanel.setPreferredSize(new java.awt.Dimension(1049, 35));

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setBackground(resourceMap.getColor("progressBar.background")); // NOI18N
        progressBar.setName("progressBar"); // NOI18N

        jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        jLabel2.setForeground(resourceMap.getColor("jLabel2.foreground")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel3.setForeground(resourceMap.getColor("jLabel3.foreground")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        javax.swing.GroupLayout statusPanelLayout = new javax.swing.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(statusPanelSeparator, javax.swing.GroupLayout.DEFAULT_SIZE, 986, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(statusAnimationLabel)
                    .addComponent(statusMessageLabel, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, statusPanelLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 624, Short.MAX_VALUE)
                        .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(statusPanelLayout.createSequentialGroup()
                .addComponent(statusPanelSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(statusPanelLayout.createSequentialGroup()
                        .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(29, 29, 29)
                        .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(statusMessageLabel)
                            .addComponent(statusAnimationLabel)))
                    .addGroup(statusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel2)
                        .addComponent(jLabel3))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, statusPanelLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(31, 31, 31)))
                .addGap(22, 22, 22))
        );

        jPanel1.setName("jPanel1"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
        addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                formPropertyChange(evt);
            }
        });
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void formPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_formPropertyChange
        // TODO add your handling code here:
    }//GEN-LAST:event_formPropertyChange

    private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
       

    }//GEN-LAST:event_jMenu1ActionPerformed

    private void btnAssociadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAssociadosActionPerformed
        try {
            abrirIFrame(new TelaAssociados());
        } catch (SQLException ex) {
            Logger.getLogger(AsfabDeskView.class.getName()).log(Level.SEVERE, null, ex);
        }

}//GEN-LAST:event_btnAssociadosActionPerformed

    private void btnFinanceiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFinanceiroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnFinanceiroActionPerformed

    private void txtBuscaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtBuscaActionPerformed
        acaoBuscar();
    }//GEN-LAST:event_txtBuscaActionPerformed

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
        acaoBuscar();
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void btnConveniosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConveniosActionPerformed
        try {
            abrirIFrame(new TelaConvenios());
        } catch (SQLException ex) {
            Logger.getLogger(AsfabDeskView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnConveniosActionPerformed

    private void menuAssociadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuAssociadosActionPerformed
        try {
            abrirIFrame(new TelaAssociados());
        } catch (SQLException ex) {
            Logger.getLogger(AsfabDeskView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_menuAssociadosActionPerformed

    private void menuConveniosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConveniosActionPerformed
        try {
            abrirIFrame(new TelaConvenios());
        } catch (SQLException ex) {
            Logger.getLogger(AsfabDeskView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_menuConveniosActionPerformed

    private void menuEmpresasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuEmpresasActionPerformed
        try {
            abrirIFrame(new TelaEmpresas());
        } catch (SQLException ex) {
            Logger.getLogger(AsfabDeskView.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_menuEmpresasActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAssociados;
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnConvenios;
    private javax.swing.JButton btnFinanceiro;
    private javax.swing.JButton btnProcessos;
    private javax.swing.JComboBox comboBusca;
    protected static javax.swing.JDesktopPane desktop;
    private javax.swing.JLabel imgLogo;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuItem menuAssociados;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JMenuItem menuConvenios;
    private javax.swing.JMenuItem menuEmpresas;
    private javax.swing.JMenuItem menuFinanceiro;
    private javax.swing.JMenuItem menuProcessos;
    private javax.swing.JPanel pnlBarraLateral;
    private javax.swing.JPanel pnlMenuPrincipal;
    private javax.swing.JPanel pnlbuscaRol;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JTextField txtBusca;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
}
